#!/usr/bin/python
# -*- encoding: utf-8 -*-

"""
@File:      tc_ag_util-linux_ipcmk_004.py
@Time:      2022/06/20 11:12:50
@Author:    zhangtaibo
@Version:   1.0
@Contact:   zhangtaibo.ztb@alibaba-inc.com
@License:   Mulan PSL v2
@Modify:    liangjian
"""

from common.basetest import LocalTest

class Test(LocalTest):
    """
    See tc_ag_util-linux_ipcmk_fun_004.yaml for details

    :avocado: tags=fix,P1,noarch,local,ag
    """
    PARAM_DIC = {"pkg_name": "util-linux"}
    def setUp(self):
        super().setUp(self.PARAM_DIC)
    
    def test(self):
        ret_c, ret_o = self.cmd("ipcmk --shmem 100 -p 600")
        self.id = ret_o.split(": ", 1)[1]
        ret_c, ret_o = self.cmd("ipcs -m |grep %s |awk '{print $4}'" % self.id)
        self.assertTrue("600" == ret_o, 'check output error.')

    def tearDown(self):
        super().tearDown(self.PARAM_DIC)
        self.cmd("ipcrm -m %s" % self.id)
